/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mscs.server.promotion.logic;

import java.text.SimpleDateFormat;
import java.util.Vector;
import mscs.data.IGoodsDiscountProxy;
import mscs.data.IToStringArrayCallBack;
import mscs.data.pojo.GoodsDiscount;

/**
 *
 * @author Usbuild
 */
public class GoodsDiscountUtil extends GiftDiscountUtil<GoodsDiscount>{

    public GoodsDiscountUtil() {
        super(new IGoodsDiscountProxy());
    }
    @Override
    public Vector<Vector<String>> toDataVector() {
        return toDataVector(new GoodsDiscountCallback());
    }
}

class GoodsDiscountCallback implements IToStringArrayCallBack {

    public Vector<String> toStringArray(Object obj) {
        if(obj != null) {
            GoodsDiscount goodsDiscount = (GoodsDiscount)obj;
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            Vector<String> stringArray = new Vector<String>();
            stringArray.add(goodsDiscount.getId());
            stringArray.add(String.valueOf(goodsDiscount.getDiscountPrice()));
            stringArray.add(sdf.format(goodsDiscount.getStartDate()));
            stringArray.add(sdf.format(goodsDiscount.getEndDate()));
            return stringArray;
        }
        return null;
    }
    
}